<?php
require('session.php');

if (empty($_GET['realm'])||empty($_GET['char']))
{
header ('Location: index.php');
}

//Check if logged in
include 'loginoptional.php';

$realm = $_GET['realm'];
$char = $_GET['char'];
//fix for realms with ' in the name
$realm = stripslashes($realm);


include 'functions.php';
include 'vars.php';

//use sliding menus here to hide rows beneath highlighted row
//<tr onMouseOver="displayRow('','row1')" onMouseOut="displayRow('none','row1')">
echo "<p>";

//show character image
echo $armoryUrl;
echo "<br/>";
echo "<br/>";


echo "Item stats: <br/>";
echo "<a class='reg' href='index.php?char=" . $char . "&realm=" . $realm . "'>Back</a>";

echo "<table class='items' onMouseOver=\"\" onMouseOut=\"displayRow('none', 'section1'); displayRow('none,'section2');
 displayRow('none,'section3'); displayRow('none,'section4'); displayRow('none,'section5');
  displayRow('none,'section6')
 \">";
echo "<tr>" . "<th scope='col'>" . "Character name: " . "</th><th scope='col'>" . $name . "</th></tr>";


//attack power
echo build_row('Attack Power',$power,'','','');
//crit chance
echo build_row_hi('Crit chance', $critchance_percent . "%",'','','','section2');	
//echo "<tbody id='section2' style='display:none'>";
echo build_row('Crit rating',$critchance_rating,'','',''); 
//echo build_row('Crit rating bonus',$critchance_plus_percent,'','%','');
//echo build_row('Agility bonus',$agility_crit,'+','%','');
//echo "</tbody>";

			   
//main hand
echo build_row_hi('Main Hand','','','','','section3');
echo "<tbody id='section3' style='display:none'>";
echo build_row('Weapon Dps',$main_dps,'','','');
echo build_row('Damage', $main_min . "-" . $main_max,'','',''); 
echo build_row('Main percent', $main_percent, '', '%' ,'');
echo build_row('Attack Speed',$main_speed,'','','Delay between attacks in seconds. Lower speed effectively increases threat.');

if ($main_haste > $main_speed)
{
echo build_row ('Haste %',$main_haste_percent,'','','');
echo build_row ('Haste rating',$main_haste_rating,'','','');  
echo build_row ('Haste',$main_haste,'','','Haste increases attack speed');  
}
echo "</tbody>";

//off hand
//echo "<tr class='highlight'>" . "<td>" . "Off Hand" . "</td><td></td></tr>";	
echo build_row_hi('Off Hand','','','','','section4');
echo "<tbody id='section4' style='display:none'>";
echo build_row('Weapon Dps',$off_dps,'','','');
echo build_row('Damage',$off_min . "-" . $off_max,'','',''); 
echo build_row('Off percent',$off_percent, '', '%' ,'');
echo build_row('Attack Speed',$off_speed,'','','Delay between attacks in seconds. Lower speed effectively increases threat.');

if ($off_haste > $off_speed)
{
echo build_row ('Haste %',$off_haste_percent,'','','');
echo build_row ('Haste rating',$off_haste_rating,'','','');  
echo build_row ('Haste',$off_haste,'','','Haste increases attack speed');  
}
echo "</tbody>";


//hit rating
echo build_row('Hit Rating', $hitRating,'','','');
//hit cap calculations
list ($singleHitCap,$singleHitCapRaid,$dualHitCap,$dualHitCapRaid,$singleHitCapVal,$singleHitCapRaidVal,$dualHitCapVal,$dualHitCapRaidVal)=hitCap($level, $hitRating);//populate variables with 1 or 0 depending on whether the toon is capped

//also want to echo the next hit cap
if ($dualWield==False)
{
	//echo "You are single wielding<br/>";
	if ($singleHitCap==0)
		{echo "<tr><td>Not hit capped for auto-attacks<br/> or special attacks against bosses at level $roundedLevel</td><td>Target: $singleHitCapVal</td></tr>";

	}
	else if ($singleHitCapRaid==0)
			{echo "<tr><td>Not hit capped for auto-attacks<br/> or special attacks against raid bosses at level $roundedLevel</td><td>Target: $singleHitCapRaidVal</td></tr>";
			}
	else
		{echo "<tr><td>Hit capped for auto/special attacks<br/> against raid bosses at level $roundedLevel</td></tr>";}
}
else
{
	//echo "You are dual wielding<br/>";
	if ($dualHitCap==0)
		{echo "<tr><td>Not hit capped for dual wield auto-attacks<br/> against bosses at level $roundedLevel</td><td>Target: $dualHitCapVal</td></tr>";}
	else if ($dualHitCapRaid==0)
			{echo "<tr><td>Not hit capped for dual wield auto-attacks<br/> against raid bosses at level $roundedLevel</td><td>Target: $dualHitCapRaidVal</td></tr>";}
	else
		{echo "<tr><td>Hit capped even for dual wield auto-attacks<br/> against raid bosses at level $roundedLevel</td></tr>";}
}

//expertise
echo build_row('', $expertise,'','','');

//display items
echo "<div id='leftitems'>";
//head
echo $itemHeadImg . "<br/>";
//neck
echo $itemNeckImg . "<br/>";
//shoulders
echo $itemShoulderImg . "<br/>";
//back
echo $itemBackImg . "<br/>";
//chest
echo $itemChestImg . "<br/>";
//shirt
echo $itemShirtImg . "<br/>";
//tabard
echo $itemTabardImg . "<br/>";
//wrist
echo $itemWristImg . "<br/>";
echo "</div>";


echo "<div id='rightitems'>"; 
//gloves
echo $itemHandsImg . "<br/>";
//belt
echo $itemWaistImg . "<br/>";
//legs
echo $itemLegsImg . "<br/>";
//feet
echo $itemFeetImg . "<br/>";
//fingers
echo $itemFinger1Img . "<br/>";
echo $itemFinger2Img . "<br/>";
//trinkets
echo $itemTrinket1Img . "<br/>";
echo $itemTrinket2Img . "<br/>";

echo "</div>";
//end item display
				
echo "</table>";
echo "</p>";
echo "<br/>";
echo "<br/>";

//display weapons
echo "<p>";
echo $itemMainHandImg . " " . $itemOffHandImg . " " . $itemRangedImg . "</p>";					

include 'footer.html';
  ?>
